home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Networking / SANA-II / slip_src / odu / source / tester.c < prev   
Encoding:
C/C++ Source or Header  |  1994-02-17  |  1.0 KB  |  54 lines

  1. /* tester */
  2.  
  3. #include <exec/lists.h>
  4. #include <proto/exec.h>
  5. #include "OwnDevUnit.h"
  6. #include <dos/dosextens.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. struct Library *OwnDevUnitBase;
  11.  
  12. main(int argc, char *argv[])
  13. {
  14.     UBYTE *RetVal;
  15.     ULONG NotifyBit;
  16.     ULONG Signal;
  17.  
  18.     if ((NotifyBit = AllocSignal(-1)) == -1) {
  19.         printf("couldn't get signal bit\n");
  20.         exit(0);
  21.     }
  22.  
  23.     if (!(OwnDevUnitBase = OpenLibrary(ODU_NAME, 3))) {
  24.         printf("couldn't open ODU.\n");
  25.         exit(0);
  26.     }
  27.  
  28.     printf("OwnerDevUnit() returned \"%s\"\n", OwnerDevUnit(argv[1], atol(argv[2])));
  29.  
  30.     RetVal = AttemptDevUnit(argv[1], atol(argv[2]), "Tester", NotifyBit);
  31.  
  32.     if (RetVal)
  33.         printf("returned \"%s\"\n", RetVal);
  34.     else
  35.         printf("obtained the lock!\n");
  36.  
  37.     if (!RetVal)
  38.         for (;;) {
  39.             Signal = Wait(SIGBREAKF_CTRL_F | (1L << NotifyBit));
  40.  
  41.             if (Signal & (1L << NotifyBit))
  42.                 printf("NotifyBit triggered\n");
  43.  
  44.             if (Signal & SIGBREAKF_CTRL_F)
  45.                 break;
  46.         }
  47.  
  48.     if (!RetVal)
  49.         FreeDevUnit(argv[1], atol(argv[2]));
  50.  
  51.     FreeSignal(NotifyBit);
  52.     CloseLibrary(OwnDevUnitBase);
  53. }
  54.